﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotSpatial.Controls;
using DotSpatial.Controls.Header;
using DotSpatial.Extensions;
using DotSpatial.Plugins.ExtensionManager;
using System.ComponentModel.Composition;
using System.IO;

namespace DotSpatial.SampleProjects.SampleProjectManager
{
    public class SampleProjectManagerPlugin : Extension 
    {
        public override void Activate()
        {
            var myButton = new SimpleActionItem(HeaderControl.ApplicationMenuKey, "Open sample project..", OpenSampleProjects_Click);
            myButton.GroupCaption = HeaderControl.ApplicationMenuKey;
            myButton.LargeImage = Properties.Resources.map32x32;
            myButton.SmallImage = Properties.Resources.map16x16;
            App.HeaderControl.Add(myButton);
            base.Activate();
        }

        public override void Deactivate()
        {
            App.HeaderControl.RemoveAll();
            base.Deactivate();
        }

        private void OpenSampleProjects_Click(object sender, EventArgs e)
        {
            TemplateForm frm = new TemplateForm(App);
            frm.ShowDialog();
        }

        private IEnumerable<string> FindSampleProjectFiles()
        {
            return Directory.EnumerateFiles(AppManager.AbsolutePathToExtensions, "*.dspx");
        }
    }
}
